package com.ncloud.crm.mapper;

import com.ncloud.crm.entity.order.OrderDiscnt;

import java.util.List;

import org.apache.ibatis.annotations.*;

@Mapper
public interface OrderDiscntMapper {
    @Insert(value = "insert into bs_o_discnt(order_id,modify_tag,discnt_inst_id,discnt_id,discnt_name,prod_inst_id,prod_id," +
            "is_base,begin_date,end_date,create_time,create_user,update_time,update_user,remark) values(#{orderId},#{modifyTag},#{discntInstId},#{discntId},#{discntName},#{prodInstId},#{prodId}," +
            "#{isBase},#{beginDate},#{endDate},#{createTime},#{createUser},#{updateTime},#{updateUser},#{remark})")
    public int insertOrderDiscnt(OrderDiscnt discnt);

    @Select("select * from bs_o_discnt where order_id = #{orderId}")
	@Results({ @Result(column = "order_id", property = "orderId"),
			@Result(column = "modify_tag", property = "modifyTag"),
			@Result(column = "discnt_inst_id", property = "discntInstId"),
			@Result(column = "discnt_id", property = "discntId"),
			@Result(column = "discnt_name", property = "discntName"),
			@Result(column = "prod_inst_id", property = "prodInstId"), @Result(column = "prod_id", property = "prodId"),
			@Result(column = "is_base", property = "isBase"), @Result(column = "begin_date", property = "beginDate"),
			@Result(column = "end_date", property = "endDate"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "create_user", property = "createUser"),
			@Result(column = "update_time", property = "updateTime"),
			@Result(column = "update_user", property = "updateUser"), @Result(column = "remark", property = "remark") })
	public List<OrderDiscnt> getDiscntByOrderId(Long orderId);

    @Update("update bs_o_discnt set begin_date=#{beginDate},end_date=#{endDate}"
    		+ " where discnt_inst_id =#{discntInstId} and modify_tag=#{modifyTag}")
	public int updateByInstId(OrderDiscnt orderDiscnt);
} 